#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <unordered_set>
#define int long long
#define x first 
#define y second  
using namespace std;
const int N = 2e6 + 10;
void solve()
{
     string s;
     cin >> s;
     int ans = 0;
     int tol = s.size() - 1;
     bool f = false;//判断有没有"QQ"
     //cout << tol << endl;
     for(int i = 1; i < s.size(); i++)
     {
         if(s[i] == 'Q' && s[i] == s[i - 1])  
         {
            f = true;
            tol -= 1;
         }
         if((i > 0 && i < s.size() - 1) && s[i] == 'L' && s[i - 1] == 'Q' && s[i + 1] == 'Q')  tol -= 1;

     }   
     if(f == true) tol += 1;
     cout << tol << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr),cout.tie(nullptr);
    int t = 1;
    while(t -- )  solve();
    return 0;
}